// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.2 OR LicenseRef-Slint-commercial

//include_path: ../../../examples/printerdemo/ui/images/

FixedWidthtImage := Image {
    source: @image-url("cat.jpg");
    width: 500phx;
}

TestCase := Rectangle {
    fixed_image := Image {
        width: 50phx;
        height: 50phx;
    }
    fixed_image_contain := Image {
        width: 50phx;
        height: 50phx;
        image-fit: contain;
    }

    VerticalLayout {
        image_in_layout := Image {
        }
        image_in_layout_with_explicit_fit := Image {
            image-fit: fill;
        }
    }

    image_with_missing_height := FixedWidthtImage {
        property <bool> expected_height_ok: self.height == 750phx;
    }

    image_with_missing_width := Image {
        source: @image-url("cat.jpg");
        height: 600phx;
        property <bool> expected_width_ok: self.width == 400phx;
    }

    image_with_missing_width_clipped := Image {
        source: @image-url("cat.jpg");
        height: 600phx;
        source-clip-width: 20;
        source-clip-height: 20;
        property <bool> expected_width_ok: self.width == 600phx;
    }

    property <bool> fixed_image_default_image_fit_ok: fixed_image.image-fit == ImageFit.fill;
    property <bool> fixed_image_image_fit_override_ok: fixed_image_contain.image-fit == ImageFit.contain;
    property <bool> image_in_layout_fit_ok: image_in_layout.image-fit == ImageFit.contain;
    property <bool> image_in_layout_custom_fit_ok: image_in_layout_with_explicit_fit.image-fit == ImageFit.fill;
    property <bool> image_with_missing_height_ok <=> image_with_missing_height.expected_height_ok;
    property <bool> image_with_missing_width_ok <=> image_with_missing_width.expected_width_ok;
    property <bool> image_with_missing_width_clipped_ok <=> image_with_missing_width.expected_width_ok;

    property <bool> test: fixed_image_default_image_fit_ok && fixed_image_image_fit_override_ok && image_in_layout_fit_ok && image_in_layout_custom_fit_ok && image_with_missing_height_ok && image_with_missing_width_ok && image_with_missing_width_clipped_ok;
}

/*

```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;
assert(instance.get_fixed_image_default_image_fit_ok());
assert(instance.get_fixed_image_image_fit_override_ok());
assert(instance.get_image_in_layout_fit_ok());
assert(instance.get_image_in_layout_custom_fit_ok());
assert(instance.get_image_with_missing_height_ok());
assert(instance.get_image_with_missing_width_ok());
assert(instance.get_image_with_missing_width_clipped_ok());
```


```rust
let instance = TestCase::new().unwrap();
assert!(instance.get_fixed_image_default_image_fit_ok());
assert!(instance.get_fixed_image_image_fit_override_ok());
assert!(instance.get_image_in_layout_fit_ok());
assert!(instance.get_image_in_layout_custom_fit_ok());
assert!(instance.get_image_with_missing_height_ok());
assert!(instance.get_image_with_missing_width_ok());
assert!(instance.get_image_with_missing_width_clipped_ok());
```

```js
var instance = new slint.TestCase();
assert(instance.fixed_image_default_image_fit_ok);
assert(instance.fixed_image_image_fit_override_ok);
assert(instance.image_in_layout_fit_ok);
assert(instance.image_in_layout_custom_fit_ok);
assert(instance.image_with_missing_height_ok);
assert(instance.image_with_missing_width_ok);
assert(instance.image_with_missing_width_clipped_ok);
```

*/
